<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>提货券修改</title>
<%@include file="../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath }/public.css" />
<script type="text/javascript" src="${jspath}/jquery/jquery-2.1.3.js"></script>
<link rel="stylesheet" type="text/css"
	href="${bootstrapPath}/css/bootstrap.css" />
<script type="text/javascript" src="${bootstrapPath}/js/bootstrap.js"></script>
<script type="text/javascript"
	src="${bootstrapPath}/js/bootstrap3-validation.js"></script>
<script type="text/javascript" src="${layerPath}/layer.js"></script>
<script type="text/javascript">
var row_count = 0;
$(function(){
	$("#returnBtn").click(function(){
		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		parent.layer.close(index); //再执行关闭 
	});
	
	$("#insertRow")
	.click(
			function() {
				var table = $("#data_tabs");
				var row = $("<tr></tr>");
				var td0 = $("<td></td>");
				var td1 = $("<td></td>");
				td0  
						.append($("<input name='attrValue' class='form-control input-sm text-left' id='valueDefine"+row_count+"' value='' type='text' style='width: 220px;'/>"));
				row.append(td0);
				td1  
						.append($("<button type='button' class='form-control btn btn-default btn-link btn-xs' id='removeRow'"
								+ " style='height:30px;width:15px;padding:0px;border: 0px;'><i class='glyphicon glyphicon-minus' style='color: green'></i></button>"));
				row.append(td1);

				table.append(row);
				row_count++;
			});
})

function confirm(){
	var s = $("#valueDefine").val();
	if(s != undefined && s != null && s != ""){
		if(row_count >= 1){
			for(var i = 0;i < row_count; i++){
				var b = $("#valueDefine"+row_count).val();
				if(b != undefined && b != null && b != ""){
					jAlert("请将信息填写完整", "提示信息");
					break;
				}
			}
		}
		$.ajax({
			type : 'POST',
			url : '${webcontext}/crmdp/dealer/coupon/savePropertyLineValue',
			data : $("#valueForm").serialize(),
			dataType : 'json',
			success : function(data) {
				
			}
		});
	}else{
		jAlert("请将信息填写完整", "提示信息");
	}
	
// 	var dataStr=$("#valueDefine").val();
// 	if (row_count >= 1) {
// 		for ( var k = 0; k < row_count; k++) {
// 			var shortName = $("#valueDefine" + k).val();
// 			if (shortName != undefined && shortName != null && shortName != "") {
// 				dataStr = shortName + "@#";
// 			}
// 		}
// 	}
}

</script>
</head>


<style>
html,body {
	overflow-y: auto;
	overflow-x:hidden;
}
.hr {
	text-align: center;
	width: 100%;
	background-color: #0071C1;
	height: 1px;
	margin-bottom: 10px;
}

.rowDiv {
	width: 100%;
    margin-left: 0;
	
}

.formDiv {
	float: left;
	width: 50%;
}

.textarea {
	width: 700px;
	height: 100px;
	max-width: 700px;
	max-height: 100px;
	resize: none;
}
.btnLength{
	width:70px;
}
.main{
  width: 400px;
  padding: 0;
  margin: 0;
}
.table tbody tr td{
	border-top: 0px solid #ddd;
}
</style>
<body>
	<div class="main" align="center">
		<div class="hr"></div>
<!-- 		<div class="form-group" style="margin-bottom: 0;"> -->
			<label class="col-sm-3 control-label" style="padding-left: 0;" for="verificationMethod">值</label>
<!-- 		</div> -->
		<form:form id="valueForm"
			action="#"
			class="form-horizontal" method="post" modelAttribute="dto"
			role="form">
			<table id="data_tabs" class="table" style="margin-top: 0; margin-left: 0;width: 60%;">
				<tbody>
					<tr>
						<td>
							<input name="attrValue" class="form-control input-sm text-left" id="valueDefine"
							value="" type="text" style="width: 220px;"/>
						</td>
						<td>
							<button type="button" class="form-control btn btn-default btn-link btn-xs" id="removeRow" style="height:30px;width:15px;padding:0px;border: 0px;">
								<i class="glyphicon glyphicon-minus" style="color: green"></i>
							</button>
						</td>
					</tr>
				</tbody>
			</table>
		</form:form>
		<div style="margin-left: 0;">
			<button type="button" class="btn btn-success btn-sm" id="insertRow">
				<i class="glyphicon glyphicon-plus" style="color: #FFFFFF"></i>&nbsp;新增
			</button>
			<button type="button" class="btn btn-success btn-sm"
				onclick="confirm()">
				<i class="glyphicon glyphicon-plus" style="color: #FFFFFF"></i>&nbsp;确定
			</button>
			<button type="button" class="btn btn-success btn-sm" id="returnBtn">
				<i class="glyphicon glyphicon-retweet" style="color: #FFFFFF"></i>&nbsp;返回
			</button>
		</div>
	</div>
</body>
</html>